﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace The_LarX
{
    public class NumberDrawer3D
    {
        public Actor ZERO;
        public Actor ONE;
        public Actor TWO;
        public Actor THREE;
        public Actor FOUR;
        public Actor FIVE;
        public Actor SIX;
        public Actor SEVEN;
        public Actor EIGHT;
        public Actor NINE;

        protected Renderer renderer;
        /// <summary>
        /// The RenderType Used
        /// </summary>
        public Renderer Renderer
        {
            get { return renderer; }
            set
            {
                renderer = value;
            }
        }

        public NumberDrawer3D(string zero,
            string one, string two, string three, string four, 
            string five, string six, string seven, string eight, 
            string nine, Renderer renderer)
        {
            ZERO = new Actor(zero);
            ONE = new Actor(one);
            TWO = new Actor(two);
            THREE = new Actor(three);
            FOUR = new Actor(four);
            FIVE = new Actor(five);
            SIX = new Actor(six);
            SEVEN = new Actor(seven);
            EIGHT = new Actor(eight);
            NINE = new Actor(nine);
            this.Renderer = renderer;

            Dictionary.Add('0', ZERO);
            Dictionary.Add('1', ONE);
            Dictionary.Add('2', TWO);
            Dictionary.Add('3', THREE);
            Dictionary.Add('4', FOUR);
            Dictionary.Add('5', FIVE);
            Dictionary.Add('6', SIX);
            Dictionary.Add('7', SEVEN);
            Dictionary.Add('8', EIGHT);
            Dictionary.Add('9', NINE);
        }

        public void SetTexture(string tex)
        {
            foreach (KeyValuePair<char, Actor> actor in Dictionary)
            {
                actor.Value.SubActors[0].TextureName = tex;
            }
        }

        public Dictionary<char, Actor> Dictionary = new Dictionary<char, Actor>();

        public virtual void DrawNumbers(string Numbers, Vector3 DegressRotation, Vector3 Position, Vector3 Direction)
        {
            for (int i = 0; i < Numbers.Length; i++)
            {
                Actor Actor = Dictionary[Numbers[i]];
                Actor.Position = Position;
                Actor.Position -= Direction * i;
                Actor.DegreesRotation = DegressRotation;
                Actor.Update();
                Actor.Draw();
                Renderer.SubmitActor(Actor);
            }
        }
    }
}
